require(['jquery','token','common/data'], function($,token,syncData) {
    var pageData=syncData.fetch();
    var content=new Vue({
        el: '.content',
        data:pageData,
        filters:{
            currency: {
                read: function (val) {
                    val=+val;
                    return val.toFixed(2)
                },
                // write 函数会在数据写入到模型之前被调用
                write: function (val, oldVal) {
                    var number = +val.replace(/[^\d.]/g, '')
                    return isNaN(number) ? 0 : parseFloat(number.toFixed(2))
                }
            },
            shopLink: function(val){
                console.log(val);
                var shopId=val;
                return '/shop/'+val;
            }

        },
        computed:{
        },
        methods:{
            locationChange:function(){
                $('#location_form').submit();
            },
            sortDefault:function(){
                window.location.reload();
            },
            sortPrice:function(event){
                this.$data.shop.sort(function(a,b){
                    return a.least_price_send-b.least_price_send;
                })
                $(event.target).siblings().removeClass('btn-primary').end().addClass('btn-primary')
            },
            goLink:function(id){
                window.location.href='/shop/'+id;
            }
        }
    })
});